package controller.api;
import com.jfinal.aop.Before;
import com.jfinal.aop.Inject;
import com.jfinal.kit.Kv;
import com.jfinal.kit.Ret;

import common.inter.ServicerStationInter;
import common.inter.StaffStationInter;
import model.GasReplace;
import service.GasReplaceService;

public class ApiGasReplaceController extends BaseApiController {
	@Inject GasReplaceService gasReplaceService ;

	@Before(StaffStationInter.class)
	public void save() {
		Long stationId = getParaToLong("stationId");
		GasReplace gasReplace = getModel(GasReplace.class , "x");
        Ret ret = gasReplaceService.save(gasReplace , getStaff() , stationId);
        renderJson(ret);
	}

	@Before(ServicerStationInter.class)
	public void list() {
	    Kv kv = getParamKv() ;
	    kv.set("tgr.stationId", getStation().getId());
	    Integer pageNumber = getParaToInt("pageNumber", 1);
	    Integer pageSize = getParaToInt("pageSize", 10);
	    set("page", gasReplaceService.getApiPage( kv , pageNumber, pageSize));
	    renderJson();
	}
}
